package com.zelin;

import io.jsonwebtoken.JwtBuilder;
import io.jsonwebtoken.Jwts;
import io.jsonwebtoken.SignatureAlgorithm;

import java.util.Date;

/**
 * @Author: Feng.Wang
 * @Company: Zelin.ShenZhen
 * @Description: 生成token
 * @Date: Create in 2019/3/28 15:13
 */
public class CreateJwtTest {
    public static void main(String[] args) {
        long times = System.currentTimeMillis();
        Date date = new Date(times + 60000);
        JwtBuilder builder = Jwts.builder().setId("111")
                .setIssuedAt(new Date())        //设置签发时间
                .setSubject("小明")
                .setExpiration(date)
                .claim("roles","admin")
                .signWith(SignatureAlgorithm.HS256, "zelin");   //设置签名秘钥
        String compact = builder.compact();
        System.out.println(compact);
    }
}
